package com.chainyoung.trademarket.mvp.presenter;


import com.chainyoung.common.base.CommonSubscriber;
import com.chainyoung.common.bean.UserInfo;
import com.chainyoung.common.di.scope.ActivityScope;
import com.chainyoung.common.mvp.BasePresenter;
import com.chainyoung.common.utils.RxUtils;
import com.chainyoung.trademarket.entity.MsgNum;
import com.chainyoung.trademarket.mvp.contract.LoginContract;
import com.chainyoung.trademarket.mvp.contract.MsgCenterContract;

import java.util.TreeMap;

import javax.inject.Inject;

@ActivityScope
public class MsgCenterPresenter extends BasePresenter<MsgCenterContract.Model,MsgCenterContract.View>{

    @Inject
    public MsgCenterPresenter(MsgCenterContract.Model model, MsgCenterContract.View rootView) {
        super(model, rootView);
    }


    public void updateMsgStatus(TreeMap<String, Object> map) {

        addSubscribe(mModel.updateMsgStatus(map)
                .compose(RxUtils.<MsgNum>rxSchedulerHelper())
                .subscribeWith(new CommonSubscriber<MsgNum>(mView,true) {
                    @Override
                    public void onNext(MsgNum data) {
                        mView.onUpdateMsgStatus(data);
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                    }
                }));
    }

}
